enum Color {
	@none
	red
	green
	blue
}

// integers may be assigned to enum fields
enum Grocery {
	apple
	orange = 5
	pear
}

enum Cycle {
	one
	two
	three
}

// enums can have methods, just like structs
fn (c Cycle) next() Cycle {
	match c {
		.one {
			return .two
		}
		.two {
			return .three
		}
		.three {
			return .one
		}
	}
}

mut color := Color.red

// No need to use `color = Color.green` here.
color = .green
println(color) // "green"

// enum match must be exhaustive or have an else branch
// reserved keywords may be escaped with an @
match color {
	.red { println('the color was red') }
	.green { println('the color was green') }
	.blue { println('the color was blue') }
	else { println('no color') }
}

color2 := Color.@none
println(color2)

// operations are not allowed on enum variables
// they must be explicitly cast to int
g1 := int(Grocery.apple)
g2 := int(Grocery.orange)
g3 := int(Grocery.pear)
println('Grocery IDs: $g1, $g2, $g3')

mut c := Cycle.one
for _ in 0 .. 10 {
	println(c)
	c = c.next()
}
